# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import logging
import sys, os
from turn import TurnToMp4
import PublicFunction as pf

tur = TurnToMp4()


def ToMp4():
    tur.m4s_to_mp4()


def truncate():
    tur.truncate()


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    star = '*'
    while True:
        print('{0} 将应用部署在容器中使用需执行以下操作 {1}'.format(star * 10, star * 10))
        print('(1)将配置文件(Config文件夹)拷贝到宿主机要挂载的目录里！')
        print('(2)将M4S视频文件夹保存到宿主机要挂载的目录里!')
        print('注意:在创建容器时,容器内的映射目录为：{0}'.format(pf.get_basic_path()))
        print('{0} 哔站视频处理 {1}'.format(star*20, star*20))
        print('[1].电脑端缓存视频去头部字节{0}[2].m4s转mp4(去头后)\r\n'.format(' ' * 4))
        print('[M].主菜单{0}[Q].退出'.format(' ' * 19))
        co = input('*按相应按键执行相应的操作：')
        low = str.lower(co)
        if low == 'q':
            exit(0)  # 在发布V2版本时用的是exit(),发现在退出时提示 NameError: name 'exit' is not defined，不知道是程序问题还是容器问题
        elif low == 'm':
            continue
        elif low == '1':
            truncate()  # [1].电脑端缓存视频处理
        elif low == '2':
            ToMp4()  # [2].电脑端缓存视频m4s转mp4


# See PyCharm help at https://www.jetbrains.com/help/pycharm/
